~ chicken-core (chicken-5) /manual/Module (chicken time posix)


 1[[tags: manual]]
 2[[toc:]]
 3
 4== Module (chicken time posix)
 5
 6This module provides procedures for conversion between seconds since
 7the epoch ("POSIX time"), strings and a 10-element vector type
 8containing the distinct time units.
 9
10
11=== seconds->local-time
12
13<procedure>(seconds->local-time [SECONDS])</procedure>
14
15Breaks down the time value represented in {{SECONDS}} into a 10
16element vector of the form {{#(seconds minutes hours mday month
17year wday yday dstflag timezone)}}, in the following format:
18
19; seconds (0) : the number of seconds after the minute (0 - 59)
20; minutes (1) : the number of minutes after the hour (0 - 59)
21; hours (2) : the number of hours past midnight (0 - 23)
22; mday (3) : the day of the month (1 - 31)
23; month (4) : the number of months since january (0 - 11)
24; year (5) : the number of years since 1900
25; wday (6) : the number of days since Sunday (0 - 6)
26; yday (7) : the number of days since January 1 (0 - 365)
27; dstflag (8) : a flag that is true if Daylight Saving Time is in effect at the time described.
28; timezone (9) : the difference between UTC and the latest local standard time, in seconds west of UTC.
29
30{{SECONDS}} defaults to
31the value of {{(current-seconds)}}.
32
33=== local-time->seconds
34
35<procedure>(local-time->seconds VECTOR)</procedure>
36
37Converts the ten-element vector {{VECTOR}} representing the time value relative to
38the current timezone into
39the number of seconds since the first of January, 1970 UTC.
40
41=== local-timezone-abbreviation
42
43<procedure>(local-timezone-abbreviation)</procedure>
44
45Returns the abbreviation for the local timezone as a string.
46
47=== seconds->string
48
49<procedure>(seconds->string [SECONDS])</procedure>
50
51Converts the time represented in {{SECONDS}} into a local-time string
52of the form {{"Tue May 21 13:46:22 1991"}}. {{SECONDS}} defaults to
53the value of {{(current-seconds)}}.
54
55=== seconds->utc-time
56
57<procedure>(seconds->utc-time [SECONDS])</procedure>
58
59Similar to {{seconds->local-time}}, but interpretes {{SECONDS}}
60as UTC time. {{SECONDS}} defaults to
61the value of {{(current-seconds)}}.
62
63=== utc-time->seconds
64
65<procedure>(utc-time->seconds VECTOR)</procedure>
66
67Converts the ten-element vector {{VECTOR}} representing the UTC time value into
68the number of seconds since the first of January, 1970 UTC.
69
70'''NOTE''': On native Windows builds (all except cygwin), this
71procedure is unimplemented and will raise an error.
72
73=== time->string
74
75<procedure>(time->string VECTOR [FORMAT])</procedure>
76
77Converts the broken down time represented in the 10 element vector
78{{VECTOR}} into a string of the form represented by the {{FORMAT}}
79string. The default time form produces something like {{"Tue May 21 13:46:22 1991"}}.
80
81The {{FORMAT}} string follows the rules for the C library procedure {{strftime}}. The default {{FORMAT}} string is {{"%a %b %e %H:%M:%S %Z %Y"}}.
82
83=== string->time
84
85<procedure>(string->time TIME [FORMAT])</procedure>
86
87Converts a string of the form represented by the {{FORMAT}} string
88into the broken down time represented in a 10 element vector. The
89default time form understands something like {{"Tue May 21 13:46:22 1991"}}.
90
91The {{FORMAT}} string follows the rules for the C library procedure {{strptime}}. The default {{FORMAT}} string is {{"%a %b %e %H:%M:%S %Z %Y"}}.
92
93
94---
95Previous: [[Module (chicken time)]]
96
97Next: [[Module (chicken type)]]
Trap